home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0145_Text Mode Copper Effects.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  2KB  |  83 lines

  1. {
  2. One the effects from the Copper demo from S!P. Very old I know and very
  3. simple, but still pretty, and not all new programmers know how control
  4. the Vgacard yet.
  5. }
  6.  
  7. Program floodfill;
  8.  
  9. uses crt;
  10.  
  11. Procedure SetGraphMode (Num:Byte);
  12. begin
  13.   asm
  14.     mov al,Num
  15.     mov ah,0
  16.     int 10h
  17.     end;
  18. end;
  19.  
  20. Procedure Hsinc;assembler;      {waits for horizontal retrace} asm
  21.       mov  dx,03dah
  22. @lab1:in   al,dx
  23.       test al,01
  24.       jnz  @lab1
  25. @lab2:in   al,dx
  26.       test al,01
  27.       jz   @lab2
  28. end;
  29.  
  30. procedure Vsinc; assembler;    {waits for vertical retrace} asm
  31.         push    ax
  32.         push    dx
  33.  
  34.         mov     dx, 03dah
  35. @@11:
  36.         in      al,dx
  37.         test    al,08h
  38.         jnz     @@11
  39. @@22:
  40.         in      al,dx
  41.         test    al,08h
  42.         jz      @@22
  43.  
  44.         pop     dx
  45.         pop     ax
  46. end;
  47.  
  48. PROCEDURE Setpalette(X,R,G,B : Byte);
  49.  
  50.  
  51. BEGIN
  52.  Port[$3C8]:=X;   Port[$3C9]:=R;
  53.  Port[$3C9]:=G;   Port[$3C9]:=B;
  54. END;  { Setpalette }
  55.  
  56. var
  57.   y,x,a,b,c:word;
  58.   ch:char;
  59.  
  60. begin
  61.   setgraphmode($13);
  62.   setpalette(255,0,0,0);
  63.   for a:=1 to 127 do setpalette(a,0,0,a div 2);
  64.   for a:=0 to 127 do setpalette(a+127,0,0,127-a div 2);
  65.   { this draws the circles. Put in a picture here instead }
  66.   for y:=1 to 420 do
  67.   for x:=1 {round(-sqrt(200*200 - y*y))} to round(sqrt(420*420 - y*y)) do
  68.           if (x<320) and (y<200) then mem[$a000:(y)*320+x]:=(X*X+Y*Y) div 64;
  69.   a:=399;
  70.   repeat
  71.   vsinc;
  72.   PORT[$3D4]:=$13;       { normal screen}
  73.   PORT[$3D5]:=40;
  74.   for b:=1 to a do HSINC;{ waits until a certain scanline position on screen}
  75.   PORT[$3D4]:=$13;       { floodfill screen screen}
  76.   PORT[$3D5]:=0;
  77.   dec(a,1);  { change here for more speed }
  78.   until (keypressed) or (a<=0);
  79.   PORT[$3D4]:=$13;
  80.   PORT[$3D5]:=40;
  81.   setgraphmode($3);
  82. end.
  83.